package com.yhq.yhqproject.base.common.web;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.List;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class ListByPageResp<T> implements Serializable {
    /**
     * 页码
     */
    private Long page;
    /**
     * 页大小
     */
    private Integer size;
    /**
     * 总数
     */
    private Long total;
    /**
     * 总页数
     */
    private Long pages;
    /**
     * 页码
     */
    private List<T> data;

    public Long getPages() {
        if (total != 0 && size != 0) {
            pages = total / size;
            if (total % size != 0) {
                pages++;
            }
        }
        return pages;
    }

}
